{% extends 'TopxiaWebBundle:Coin:layout.html.twig' %}
{% block title %}{{'我的邀请码'|trans}} - {{ parent() }}{% endblock %}

{% set side_nav = 'my-invite-code' %}

{% block main %}
  <div class="es-section ">
  {% include 'TopxiaWebBundle:Coin:bill-bar.html.twig' %}
  {% if setting('invite.invite_code_setting') == 1 %}
    <p class="clearfix">
    <span class="label label-primary label-md mrl">{{'我的邀请码'|trans}}</span><span class="mrl text-xlg">{{code}}</span>
    {% if record == null %}
    <a  class="btn btn-primary btn-sm pull-right mlm" href="#modal" data-toggle="modal" id="writeInvite" data-url="{{ path('write_invitecode')}}">{{'TA的邀请码'|trans}}</a>
    {% endif %}
    <a  class="btn btn-primary btn-sm pull-right" href="#modal" data-toggle="modal" data-url="{{ path('invite_promote_link')}}">{{'邀请好友'|trans}}</a></p>
    <br>
    <div class="alert alert-warning">
    {{'给TA分享您的邀请码或者邀请链接'|trans}}
    {% if setting('invite')|default(false) %}
      {% if setting('invite.promoted_user_value')|default(false)  %}
        {% trans with {'%promoted_user_value%': inviteSetting.promoted_user_value} %}，TA注册后将获得%promoted_user_value%元优惠券{% endtrans %}
      {% endif %}

      {% if setting('invite.promote_user_value')|default(false) %}
        ，
        {% if setting('invite.get_coupon_setting')|default(false) %}
          {% trans with {'%promote_user_value%': inviteSetting.promote_user_value} %}
            TA在消费后您将获得%promote_user_value%元优惠券
          {% endtrans %}
        {% else %}
          {% trans with {'%promote_user_value%': inviteSetting.promote_user_value} %}   
            同时您将获得%promote_user_value%元优惠券
          {% endtrans %}
        {% endif %}
      {% endif %}
    {{'。'|trans}}
    {% else %}
    {{'。'|trans}}
    {% endif %}
    </div>


<table class="table table-striped table-hover" id="course-table" style="word-break:break-all;">
  <thead>
    <tr>
      <th>{{'邀请对象'|trans}}</th>
      <th>{{'邀请时间'|trans}}</th>
      <th>{{'邀请奖励'|trans}}</th>
      <th>{{'奖励获取时间'|trans}}</th>
    </tr>
  </thead>
  <tbody>
      {% for user in invitedUsers %}
      <tr>
        <td>{{user.nickname}}</td>
        <td>{{user.inviteTime|date('Y-m-d H:i:s')}}</td>
        <td>{{user.rewardRate|default('-')}}</td>
        <td>{{user.inviteRewardTime|default('-')}}</td>
      </tr>
      {% else %}
        <tr><td colspan="20"><div class="empty">{{'暂无邀请用户'|trans}}</div></td></tr>
      {% endfor %}
  </tbody>
</table>
  {{ web_macro.paginator(paginator) }}


  {% else %}
  <div class="well" style="text-align:center;">
    {{'邀请码功能已关闭'|trans}}
  </div>
  {% endif %}
  </div>
{% endblock %}